/**
 * Created by lee_mxue on 17/4/27.
 */
import React from "react"
import ReactDOM from "react-dom"
require('../../styles/common.less');
require('../../lib/rem')
let MyCarousel = require ('../../components/PictureSlick')
let SendOffCard = require ('../../components/SendOffCard')
import { addErrorListener } from "../../lib/handleError"
import Clipboard from "clipboard"
const Toast = require('../MyPackage/components/Toast')

class App extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
        }
    }

    componentWillMount() {
        addErrorListener()()
    }
    componentDidMount() {
        new Clipboard('.btn')
    }

    putInClipboard() {
        var clipboard = new Clipboard(this.refs.contactService, {
            // 点击copy按钮，直接通过text直接返回复印的内容
            text: ()=> {
                return '订单号：' + this.state.exp_code;
            }
        });

        clipboard.on('success', function (e) {
            alert('success')
        });

        clipboard.on('error', function (e) {
            alert('fail')
        });
    }

    simulate() {

    }
    copy() {
        Toast.success({
            content: "copy成功"
        })
    }
    
    render() {
        return (
            <div>
                <button onClick={this.simulate.bind(this)}>一个按钮</button>
                <a ref="contactService" onClick={this.putInClipboard.bind(this)} href="javascript:;"
                className="weui-btn weui-btn_white textGray">联系客服</a>
                <button className="btn weui-btn weui-btn_white textGray" data-clipboard-text="Just because you can doesn't mean you should — clipboard.js"
                    onClick={this.copy.bind(this)}>
                    点击复制
                </button>
            </div>

        )
    }
}
ReactDOM.render(<App />, document.getElementById('app'))
if (module.hot) {
    module.hot.accept();
}